/*
 * @Author: suxunying
 * @desc: user action
 * @Date: 2021-07-22 19:25:56
 * @LastEditors: suxunying
 * @LastEditTime: 2021-07-26 10:23:33
 * @FilePath: \bmp-poc\plat\src\shared\modules\user\action.ts
 */
import pool from '../../pool';

interface UserInfo {
    username: string,
}

export const userAction = {
    name: 'user',
    getUserinfo: (): UserInfo | Record<string, never> => {
        const state = pool.getState();
        return state.user.userinfo || {};
    },
    setUserinfo: (userinfo: UserInfo): void => {
        pool.dispatch({
            type: 'SET_USERINFO',
            payload: userinfo,
        });
    },
};
